<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="yes" />
<title><?=$da['title']?></title>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="<?=$da['p']?>/css/cssm.css">
<link rel="stylesheet" type="text/css" href="mode/plugin/css/jquery-rockdatepicker.css"/>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/js.js"></script>
<script type="text/javascript" src="js/base64-min.js"></script>
<script type="text/javascript" src="mode/plugin/jquery-rockdatepicker.js"></script>

<script type="text/javascript">
var editor,arr=<?=$da['fieldsjson']?>,moders=<?=json_encode($da['moders'])?>,isedit=1,mid='<?=$da['mid']?>';
function initbodys(){};
function geturlact(act){
	var url=js.getajaxurl(act,'mode_'+moders.num+'|input','flow');
	return url;
}
function changesubmit(d){};
function changesubmitbefore(){};
function initbody(){
	c.initdatelx();
	initbodys();
}
var c={
	initdatelx:function(){
		var o = $("input[inputtype]").click(function(){
			$(this).unbind('click');
			var lx = $(this).attr('inputtype');
			c.date(this, lx);
			return false;
		});
	},
	save:function(){
		if(js.ajaxbool||isedit==0)return;
		js.setmsg('');
		var len = arr.length,i,val,fid;
		changesubmitbefore();
		var d = js.getformdata();
		for(i=0;i<len;i++){
			fid=arr[i].fields;
			if(arr[i].isbt=='1'){
				val=d[fid];
				if(isempt(val)){
					if(form(fid))form(fid).focus();
					js.msg('msg',''+arr[i].name+'不能为空');
					return;
				}
			}
		}
		var s=changesubmit(d);
		if(typeof(s)=='string'&&s!=''){
			js.msg('msg',s);
			return false;
		}
		if(typeof(s)=='object')d=js.apply(d,s);
		d.modeid=moders.id;
		d.modenum=moders.num;
		js.msg('wait','保存中...');
		get('AltS').disabled=true;
		js.ajax(geturlact('save'),d,function(str){
			c.backsave(js.decode(str));
		}, 'post', function(){
			js.setmsg('error:内部错误,可F12调试');
		});
	},
	backsave:function(a){
		if(a.success){
			js.msg('success','提交成功');
			this.formdisabled();
			$('#AltS').hide();
			form('id').value=a.data;
			isedit=0;
			js.sendevent('reload', 'yingyong_mode_'+moders.num+'');
			js.backla();
		}else{
			get('AltS').disabled=false;
			js.msg('msg',a.msg);
		}
	},
	formdisabled:function(){
		$('form').find('*').attr('disabled', true);
		$('#fileupaddbtn').remove();
	},
	date:function(o1,lx){
		$(o1).rockdatepicker({view:lx,initshow:true});
	},
	changeuser:function(na, lx){
		changeuser(na,lx);
		return false;
	},
	changeclear:function(na){
		clearuser(na);
	}
}
var changename_uuusw;
function changeuser(na,lx){
	changename_uuusw=na;
	if(!lx)lx='';
	var url='task.php?fn=dept&adminid='+adminid+'&token='+token+'&changetype='+lx+'';
	var s='<div style="height:100%;width:100%;position:fixed;top:0px;left:0px;z-index:99; background:rgba(0,0,0,0.2)"  align="center" id="changmodddid">';
	s+='<div style="max-width:300px;height:100%;max-height:450px;margin-top:5%; background:while;border:1px #dddddd solid">';
	s+='<iframe style="background:white" name="changdept" height="100%" frameborder="0" scrolling="auto" marginheight="0" marginwidth="0" width="100%" src="'+url+'"></iframe>';
	s+='</div>';
	s+='</div>';
	$('body').append(s);
}
function changecancel(){
	$('#changmodddid').remove();
}
function changeok(sna,sid){
	get(changename_uuusw).value=sna;
	get(changename_uuusw+'_id').value=sid;
}
function clearuser(na){
	get(na).value='';
	get(na+'_id').value='';
	get(na).focus();
}
</script>
<style>
.datesss{background:url(mode/icons/date.png) no-repeat right;cursor:pointer}
input,textarea,select,*{font-size:16px}
</style>
</head>

<body class="mbody">
<div>
	<form name="myform">
		<input name="id" type="hidden" value="<?=$da['mid']?>">
		<?=$da['content']?>
	</form>
	<div class="padding10">
		<input type="button" id="AltS" onclick="c.save()" class="btn" value="提交">
		<div id="msgview"></div>
	</div>
</div>
<script type="text/javascript" src="<?=$da['p']?>/flow/input/inputjs/mode_<?=$da['moders']['num']?>.js"></script>
</body>
</html>